package com.byedu.course;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.byedu.domain.course.AnswerDO;
import com.byedu.domain.course.vo.AnswerVO;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.byedu.mapper.course.AnswerMapper;

/**
 * Created by Luo on 2017-04-25.
 */
@Service
public class AnswerService {

    @Autowired
    private AnswerMapper answerMapper;




    /**
     * 获取考题集对应的答案，即对应的选项集
     * @author chenxigui
     * @date 2017-04-26
     * @param questionId
     * @return
     */
    public  List<AnswerVO> listAnswersbyQuestionId(int questionId) {
        return convertDoListToVoList(answerMapper.listAnswersbyQuestionId(questionId));
    }

    public List<AnswerVO> convertDoListToVoList(List<AnswerDO> answerDOList) {
        if (CollectionUtils.isNotEmpty(answerDOList)) {
            List<AnswerVO> answerVOList = new ArrayList<AnswerVO>();
            for (AnswerDO answerDO : answerDOList) {
                AnswerVO answerVO = new AnswerVO(answerDO);
                answerVOList.add(answerVO);
            }

            return answerVOList;
        }

        return null;
    }

}
